package com.gmrz.uaf.db.dao;

import com.gmrz.uaf.db.DAOException;
import com.gmrz.uaf.protocol.v1.schema.*;

import java.util.List;
import java.util.Set;

public interface AuthenticatorDAO {
    void insert(Authenticator paramAuthenticator) throws DAOException;

    boolean delete(Authenticator authenticator, int status) throws DAOException;

    /**
     * 查询当前设备上用户注册信息
     *
     * @param userName
     * @param appID
     * @param deviceID
     * @return
     * @throws DAOException
     */
    List<Authenticator> findUserOnDevice(String userName, String appID, String deviceID) throws DAOException;

    List<Authenticator> findUserOnRemoteAuthType(String userName, String appID) throws DAOException;

    /**
     * 查询当前设备上用户的指定认证方式注册信息
     *
     * @param userName
     * @param appID
     * @param deviceID
     * @param authType
     * @param transType
     * @param status
     * @return
     * @throws DAOException
     */
    Set<Authenticator> findUserOnDevice(String userName, String appID, String deviceID, String authType, String transType, int status) throws DAOException;

    Set<Authenticator> findUserOnDeviceDer(String userName, String appID, String deviceID, String authType, String transType, int status) throws DAOException;

    /**
     * 查询当前用户的指定认证方式注册信息
     *
     * @param userName
     * @param appID
     * @param authType
     * @param transType
     * @param status
     * @return
     * @throws DAOException
     */
    Set<Authenticator> findUserNoDevice(String userName, String appID, String authType, String transType, int status) throws DAOException;

    /**
     * 查询当前用户的指定认证方式注册信息
     *
     * @param userName
     * @param appID
     * @param authType
     * @param transType
     * @param status
     * @return
     * @throws DAOException
     */
    Set<Authenticator> findUserNoDeviceDer(String userName, String appID, String authType, String transType, int status) throws DAOException;


    /**
     * 查询用户所有设备上的指定认证方式注册信息
     *
     * @param userName
     * @param appID
     * @return
     * @throws DAOException
     */
    Set<Authenticator> findUserOnAllDevice(String userName, String appID) throws DAOException;

    /**
     * 查询用户注册信息
     *
     * @param appID
     * @param aliasName
     * @param aaid
     * @param keyID
     * @return
     * @throws DAOException
     */
    Authenticator findUser(String appID, String aliasName, String aaid, String keyID)
            throws DAOException;

    /**
     * 更新用户sign
     *
     * @param signCounter
     * @param appID
     * @param userName
     * @param aaid
     * @param keyID
     * @return
     * @throws DAOException
     */
    int updateSignCounter(int signCounter, String appID, String userName, String aaid, String keyID)
            throws DAOException;

    /**
     * 查询用户注册数量
     *
     * @param paramString
     * @param appID
     * @return
     * @throws DAOException
     */
    int getActiveRegCount(String paramString, String appID)
            throws DAOException;

    /**
     * 更新device
     *
     * @param userName
     * @param appID
     * @param deviceID
     * @param authType
     * @param transType
     * @throws DAOException
     */
    void updateDevice(String userName, String appID, String deviceID,
                      String authType, String transType) throws DAOException;

    /**
     * 更新状态和时间
     *
     * @param userName
     * @param appID
     * @param authType
     * @param transType
     * @throws DAOException
     */
    void updateOther(String userName, String appID, String authType, String transType) throws DAOException;
    void updateOtherByDeviceID(String userName, String appID, String authType, String transType,String deviceID) throws DAOException;

    /**
     * 增加指纹
     *
     * @param appID
     * @param userName
     * @param aaid
     * @param keyID
     * @param uvsJson
     * @param uvi
     * @throws DAOException
     */
    void addUvi(String appID, String userName, String aaid, String keyID, String uvsJson, String uvi) throws DAOException;

    void insertCertificate(CertificateBean certificateBean) throws DAOException;

    List<UserInfoBean> findUser(String hashedUserName, String appID, String deviceID, List<String> authType, List<String> transType) throws DAOException;

    CertificateBean findCertByAuthId(String id) throws DAOException;

    List<CertificateBean> findCertByDeviceId(String deviceID, int secureLevel) throws DAOException;

    long findMaxCount() throws DAOException;

    long findMaxCount(String securityLevel) throws DAOException;

    void deleteCert(String authId)throws DAOException;

    int getCertActiveRegCount(String username,String authType)throws DAOException;

    boolean deleteAuth(Authenticator authenticator)throws DAOException;

    List<Authenticator> findAuthenticatorAndCertInfo(String userName, String deviceId,List<String> authType,String appID)throws DAOException;

    void insertCertificateExtend(CertificateExtendBean certificateExtendBean)throws DAOException;

    Authenticator findAuthenticator(String appID, String userName, String keyID)throws DAOException;

    int updateCertStatus(String id,int fromStatus,int toStatus)throws DAOException;

    void updateCertDNIndex(String cardType, String cardName, String cardNO, int dnIndex)throws DAOException;

    void insertCertDNIndex(String cardType, String cardName, String cardNO, int dnIndex)throws DAOException;

    public CertificateExtendBean getCertificateExtend(String authId , String authType) throws DAOException;

    void insertOOBCode(OOBCodeBean oobCodeBean)throws DAOException;

    void updateOOBCodeStatus(String authToken ,int fromStatus, int toStatus)throws DAOException;

    void updateOOBCode(OOBCodeBean oobCodeBean)throws DAOException;

    public OOBCodeBean findOOBCode(String authToken) throws DAOException;
    public void updateCertExtend(String activateAppID ,String authID,String activateType) throws DAOException;

    void insertCertUpdateRecord(String userName, String custNo, String deviceID, String appID, String authType, String transType)throws DAOException;

    void deleteCertExtend(String authID, String appID, String cancelReason)throws DAOException;

    int updateCertUpdateRecord(String userName, String deviceID, String authType, String transType,String authID)throws DAOException;

    Set<Authenticator> findUserByDeviceIDAndAppID(String deviceID, String appID, String authType, String transType, int status)throws DAOException;

    int selectCertCountByDeviceIDAndSecurityLevel(String deviceID, String securityLevel)throws DAOException;


    List<AuthenticatorRegList> queryRegListByUseNameAndTenantID(String userName, String appID, String transType, String authType) throws DAOException;

}
